import * as API from '@/api/movie.js';

export default {
  namespaced: true,
  state() {
    return {
      hotMovieList: [],
      cinemaList: [],
    };
  },
  mutations: {
    SET_HOT_MOVIE_LIST(state, payload) {
      state.hotMovieList = payload;
    },
    SET_CINEMA_LIST(state, payload) {
      state.cinemaList = payload;
    }
  },
  actions: {
    async updateHotMovieList({ commit }) {
      const res = await API.getHotMovieList();
      commit('SET_HOT_MOVIE_LIST', res);
    },
    async updateCinemaList({ commit }) {
      const res = await API.getCinemaList();
      commit('SET_CINEMA_LIST', res);
    }
  },
};
